
// imeisn = "868802049323827";
//要查的sn码
var asus="null";

var tmpScCode = getScCode();

console.log("countryId=",countryId);


    //通过门店国家 005 查询集成开关明细，若能查询到则显示 绑定标示和丢失标示字段；若未能查询到 隐藏绑定标示和丢失标示字段 2017/8/3 李文涛
    var fetchXML = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false' no-lock='true'>\
                               <entity name='hw_integratedswitchcountry'>\
                               <attribute name='hw_integratedswitchcountryid' />\
                               <attribute name='hw_name' />\
                               <filter type='and'>\
                               <condition attribute='hw_country' operator='eq'  uitype='hw_country' value='" + countryId + "' />\
                               <condition attribute='statecode' operator='eq' value='0' />\
                               </filter>\
                               <link-entity name='hw_integratedswitch' from='hw_integratedswitchid' to='hw_integratedswitch' alias='aa'>\
                               <filter type='and'>\
                               <condition attribute='hw_switchcode' operator='eq' value='005' />\
                               <condition attribute='statecode' operator='eq' value='0' />\
                               </filter>\
                               </link-entity>\
                               </entity>\
                               </fetch>";
if (countryId != "") {
    CRM.Common.querySync('hw_integratedswitchcountries?fetchXml=' + fetchXML, false, function (ret) {
    }, function (err) { })
}


RightInfoUrl = "DeviceRightSync/api/DeviceRight/GetDeviceRightInfoBySNOrIMEI?snimei=" + imeisn + "&langType=" + lcid;
BaseInfoUrl = "DeviceRightSync/api/DeviceRight/GetDeviceBaseInfoBySNOrIMEI?snimei=" + imeisn + "&langType=" + lcid + "&countryCode=" + countryCode + "&partnerCode=" + scCode + "&filterReturnImei=0";//返回政企客户名称新接口调用 2017/8/2  李文涛
AntecedentsInfoUrl = "DeviceRightSync/api/DeviceRight/GetDeviceAntecedentsInfoBySNOrIMEI?snimei=" + imeisn + "&langType=" + lcid + "&countryCode=" + countryCode;

console.log("getMiddleWareDatas");
console.log("BaseInfoUrl=",BaseInfoUrl);
var startTimestamp=new Date().getTime();
//同步
// 第二个参数为 true 是异步
CRM.Common.getMiddleWareDatas(BaseInfoUrl, false, function (result) {
    console.log("-----------aaaa");
    console.log("result=",result);
    if (result.ResCode == "000") {
        if (result.ResMessage == "success") {
            var deviceinfo = result.ResBody;
            console.log("asus="+asus);
            asus=deviceinfo;
        } else {
            console.log(result);
            asus="error";
        }
    }
}, function (req) {
    console.log(req);
});
var endTimestamp=new Date().getTime();
console.log("time=",(endTimestamp-startTimestamp));
return asus;
